import * as actionTypes from './actionTypes';

const initState = {
  categoryList:[],
  excellentBooks:[],
  newBooks:[],
  page:1,
  pageSize:10,
  total:1,
  currentPage:1,
  hotBooks:[]
};
export default (state = initState,action) => {
  switch (action.type) {
    case actionTypes.SET_CATEGORY:
      return Object.assign({},state,{categoryList:action.categoryList});

    case actionTypes.SET_EXCELLENTBOOKS:
      return Object.assign({},state,{excellentBooks:action.excellentBooks});

    case actionTypes.SET_TOTAL:
      return Object.assign({},state,{total:action.total});

    case actionTypes.SET_CURRENTPAGE:
        return Object.assign({},state,{currentPage:action.currentPage});

    case actionTypes.SET_NEWBOOKS:
        return Object.assign({},state,{newBooks:action.newBooks});

    case actionTypes.SET_HOTBOOKS:
      return Object.assign({},state,{hotBooks:action.hotBooks});
    
    default:
      return state;
  }
}
